package com.zzhrtech.wgzx_cityzen.beans.contact;

import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by renxiangpeng on 16/9/20.
 */
public class ActivListBean {
    String code;
    String msg;

    List<Data> data;


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<Data> getData() {
        return data;
    }

    public void setData(List<Data> data) {
        this.data = data;
    }

    public static class Data{
        String imgTh;
        String img;
        String play;
        String name;
        String startTime;
        String endTime;
        String id;
        String type;
        String shijian;
        String canplay;
        boolean isend;
        String stringtime;
        String stringflag;

        public String getShijian() {
            return shijian;
        }

        public void setShijian(String shijian) {
            this.shijian = shijian;
        }

        public boolean getIsend() {
            SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            try {
                Date end = sDateFormat.parse(endTime);
                Date now = sDateFormat.parse(shijian);

                return now.after(end);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return isend;
        }

        public String getStringflag() {
            return getIsend() ? "已结束" : getCanplay() ? "进行中" : "已参加";
        }

        public boolean getCanplay() {
            return canplay.equals("1");
        }

        public void setCanplay(String canplay) {
            this.canplay = canplay;
        }

        public boolean isend() {
            return isend;
        }

        public void setIsend(boolean isend) {
            this.isend = isend;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getImgTh() {
            return imgTh;
        }

        public void setImgTh(String imgTh) {
            this.imgTh = imgTh;
        }

        public String getImg() {
            return img;
        }

        public void setImg(String img) {
            this.img = img;
        }

        public String getPlay() {
            return play;
        }

        public void setPlay(String play) {
            this.play = play;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getStartTime() {
            return startTime;
        }

        public void setStartTime(String startTime) {
            this.startTime = startTime;
        }

        public String getEndTime() {
            return endTime;
        }

        public String getStringtime() {

            SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sDateFormat1 = new SimpleDateFormat("yyyy.MM.dd");

            try {
                Date start = sDateFormat.parse(startTime);
                Date end = sDateFormat.parse(endTime);
                return sDateFormat1.format(start) + " - " + sDateFormat1.format(end);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            return stringtime;
        }

        public void setEndTime(String endTime) {
            this.endTime = endTime;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }

    public boolean isSuccess(){
        return code.equals("0");
    }

}
